.\" $OpenBSD: pthread_condattr_init.3,v 1.2 2013/06/05 03:44:50 tedu Exp $
.\"
.\" Copyright (C) 2000 Jason Evans <jasone@freebsd.org>.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice(s), this list of conditions and the following disclaimer as
.\"    the first lines of this file unmodified other than the possible
.\"    addition of one or more copyright notices.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice(s), this list of conditions and the following disclaimer in
.\"    the documentation and/or other materials provided with the
.\"    distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
.\" BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
.\" OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
.\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $FreeBSD: pthread_mutexattr.3,v 1.5 2001/07/15 07:53:26 dd Exp $
.Dd $Mdocdate: June 5 2013 $
.Dt PTHREAD_CONDATTR_INIT 3
.Os
.Sh NAME
.Nm pthread_condattr_init ,
.Nm pthread_condattr_destroy ,
.Nm pthread_condattr_setclock ,
.Nm pthread_condattr_getclock
.Nd condition variable attribute operations
.Sh SYNOPSIS
.In pthread.h
.Ft int
.Fn pthread_condattr_init "pthread_condattr_t *attr"
.Ft int
.Fn pthread_condattr_destroy "pthread_condattr_t *attr"
.Ft int
.Fn pthread_condattr_setclock "pthread_condattr_t *attr" "clockid_t clock_id"
.Ft int
.Fn pthread_condattr_getclock "pthread_condattr_t *attr" "clockid_t *clock_id"
.Sh DESCRIPTION
Condition variable attributes are used to specify parameters to
.Fn pthread_cond_init .
One attribute object can be used in multiple calls to
.Fn pthread_cond_init ,
with or without modifications between calls.
.Pp
The
.Fn pthread_condattr_init
function initializes
.Fa attr
with all the default condition variable attributes.
.Pp
The
.Fn pthread_condattr_destroy
function destroys
.Fa attr .
.Pp
The
.Fn pthread_condattr_setclock
function sets the clock attribute of
.Fa attr
to the value of the
.Fa clock_id
parameter.
The
.Fn pthread_condattr_getclock
function copies the value of the clock attribute from
.Fa attr
to the location pointed to by the
.Fa clock_id
parameter.
The clock attribute is the ID of the clock against which the timeout of
.Fn pthread_cond_timedwait
is compared;
the default value of the clock attribute is
.Dv CLOCK_REALTIME .
.Sh RETURN VALUES
If successful, these functions return 0.
Otherwise, an error number is returned to indicate the error.
.Sh ERRORS
.Fn pthread_condattr_init
will fail if:
.Bl -tag -width Er
.It Bq Er ENOMEM
Out of memory.
.El
.Pp
.Fn pthread_condattr_setclock
will fail if:
.Bl -tag -width Er
.It Bq Er EINVAL
The value of
.Fa clock_id
is neither
.Dv CLOCK_REALTIME
nor
.Dv CLOCK_MONOTONIC .
.El
.Sh SEE ALSO
.Xr clock_gettime 2 ,
.Xr pthread_cond_init 3
.Sh STANDARDS
.Fn pthread_condattr_init ,
.Fn pthread_condattr_destroy ,
.Fn pthread_condattr_setclock ,
and
.Fn pthread_condattr_getclock
conform to
.St -p1003.1-2008
